home *** CD-ROM | disk | FTP | other *** search
Wrap
RRRRWWWWppppoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) RRRRWWWWppppoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) NNNNaaaammmmeeee RWpostream - Rogue Wave library class SSSSyyyynnnnooooppppssssiiiissss #include <rw/pstream.h> // Construct an RWpostream, using cout's streambuf: RWpostream pstr(cout) ; DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn Class RRRRWWWWppppoooossssttttrrrreeeeaaaammmm specializes the abstract base class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm to store variables in a portable (printable) ASCII format. The results can be restored by using its counterpart RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm. You can think of RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm and RRRRWWWWppppoooossssttttrrrreeeeaaaammmm as an ASCII veneer over an associated streambuf which are responsible for formatting variables and escaping characters such that the results can be interchanged between any machines. As such, they are slower than their binary counterparts RRRRWWWWbbbbiiiissssttttrrrreeeeaaaammmm and RRRRWWWWbbbboooossssttttrrrreeeeaaaammmm which are more machine dependent. Because RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm and RRRRWWWWppppoooossssttttrrrreeeeaaaammmm retain no information about the state of their associated ssssttttrrrreeeeaaaammmmbbbbuuuuffffs, their use can be freely exchanged with other users of the ssssttttrrrreeeeaaaammmmbbbbuuuuffff (such as iiiissssttttrrrreeeeaaaammmm or iiiiffffssssttttrrrreeeeaaaammmm). The goal of class RRRRWWWWppppoooossssttttrrrreeeeaaaammmm and RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm is to store variables using nothing but printable ASCII characters. Hence, nonprintable characters must be converted into an external representation where they can be recognized. Furthermore, other characters may be merely bit values (a bit image, for example), having nothing to do with characters as symbols. For example, RWpostream pstrm(cout); char c = '0; pstr << c; // Stores "newline" pstr.put_; // Stores the number 10. The expression "ppppssssttttrrrr <<<<<<<< cccc" treats cccc as a symbol for a newline, an unprintable character. The expression "ppppssssttttrrrr....ppppuuuutttt____" treats cccc as the literal number "10". NNNNooootttteeee tttthhhhaaaatttt vvvvaaaarrrriiiiaaaabbbblllleeeessss sssshhhhoooouuuulllldddd nnnnooootttt bbbbeeee sssseeeeppppaaaarrrraaaatttteeeedddd wwwwiiiitttthhhh wwwwhhhhiiiitttteeee ssssppppaaaacccceeee. Such white space would be interpreted literally and would have to be read back in as a character string. RRRRWWWWppppoooossssttttrrrreeeeaaaammmm can be interrogated as to the stream state using member functions ggggoooooooodddd(((()))), bbbbaaaadddd(((()))), eeeeooooffff(((()))),pppprrrreeeecccciiiissssiiiioooonnnn(((()))), eeeettttcccc. PPPPaaaaggggeeee 1111 RRRRWWWWppppoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) RRRRWWWWppppoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) Persistence None EEEExxxxaaaammmmpppplllleeee See RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm for an example of how to read back in the results of this program. The symbol "o" is intended to represent a control-G, or bell. .cpp #include <rw/pstream.h> main(){ // Construct an RWpostream to use standard output: RWpostream pstr(cout); int i = 5; float f = 22.1; double d = -0.05; char string[] = "A string withtabs,0ewlines and a o bell."; pstr << i; // Store an int in binary pstr << f << d; // Store a float & double pstr << string; // Store a string } PPPPrrrrooooggggrrrraaaammmm oooouuuuttttppppuuuutttt:::: 5 22.1 -0.05 "A string withtabs,0ewlines and a bell." PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss RRRRWWWWppppoooossssttttrrrreeeeaaaammmm(streambuf* s); Initialize an RRRRWWWWppppoooossssttttrrrreeeeaaaammmm from the ssssttttrrrreeeeaaaammmmbbbbuuuuffff ssss. RRRRWWWWppppoooossssttttrrrreeeeaaaammmm(ostream& str); PPPPaaaaggggeeee 2222 RRRRWWWWppppoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) RRRRWWWWppppoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) Initialize an RRRRWWWWppppoooossssttttrrrreeeeaaaammmm from the ssssttttrrrreeeeaaaammmmbbbbuuuuffff associated with the output stream ssssttttrrrr. PPPPuuuubbbblllliiiicccc DDDDeeeessssttttrrrruuuuccccttttoooorrrr virtual ~~~~RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm(); This virtual destructor allows specializing classes to deallocate any resources that they may have allocated. PPPPuuuubbbblllliiiicccc OOOOppppeeeerrrraaaattttoooorrrrssss virtual RWvostream& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(const char* s); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the character string starting at ssss to the output stream using a portable format. The character string is expected to be null terminated. virtual RWvostream& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(const wchar_t* ws); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the wide character string starting at wwwwssss to the output stream using a portable format. The character string is expected to be null terminated. virtual RWvostream& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(char c); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the char cccc to the output stream using a portable format. Note that cccc is treated as a character, not a number. This member attempts to preserve the symbolic characters values transmitted over the stream virtual RWvostream& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(wchar_t wc); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the wwwwiiiiddddeeee cccchhhhaaaarrrr wwwwcccc to the output stream using a portable format. Note that wwwwcccc is treated as a character, not a number. virtual RWvostream& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(unsigned char c); PPPPaaaaggggeeee 3333 RRRRWWWWppppoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) RRRRWWWWppppoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the uuuunnnnssssiiiiggggnnnneeeedddd cccchhhhaaaarrrr cccc to the output stream using a portable format. Note that cccc is treated as a character, not a number. virtual RWvostream& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(double d); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the ddddoooouuuubbbblllleeee dddd to the output stream using a portable format. virtual RWvostream& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(float f); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the ffffllllooooaaaatttt ffff to the output stream using a portable format. virtual RWvostream& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(int i); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the iiiinnnntttt iiii to the output stream using a portable format. virtual RWvostream& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(unsigned int i); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the uuuunnnnssssiiiiggggnnnneeeedddd iiiinnnntttt iiii to the output stream using a portable format. virtual RWvostream& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(long l); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the lllloooonnnngggg llll to the output stream using a portable format. virtual RWvostream& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(unsigned long l); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the uuuunnnnssssiiiiggggnnnneeeedddd lllloooonnnngggg llll to the output stream using a portable format. virtual RWvostream& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(short s); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the sssshhhhoooorrrrtttt ssss to the output stream using a portable format. PPPPaaaaggggeeee 4444 RRRRWWWWppppoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) RRRRWWWWppppoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) virtual RWvostream& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(unsigned short s); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the uuuunnnnssssiiiiggggnnnneeeedddd sssshhhhoooorrrrtttt ssss to the output stream using a portable format. ooooppppeeeerrrraaaattttoooorrrr vvvvooooiiiidddd****(); Inherited via RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm from RRRRWWWWvvvviiiioooossss. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss int pppprrrreeeecccciiiissssiiiioooonnnn() const; Returns the currently set precision used for writing ffffllllooooaaaatttt and ddddoooouuuubbbblllleeee data. At construction, the precision is set to RRRRWWWW____DDDDEEEEFFFFAAAAUUUULLLLTTTT____PPPPRRRREEEECCCCIIIISSSSIIIIOOOONNNN (defined in ccccoooommmmppppiiiilllleeeerrrr....hhhh.) int pppprrrreeeecccciiiissssiiiioooonnnn(int p); Changes the precision used for writing ffffllllooooaaaatttt and ddddoooouuuubbbblllleeee data. Returns the previously set precision. At construction, the precision is set to RRRRWWWW____DDDDEEEEFFFFAAAAUUUULLLLTTTT____PPPPRRRREEEECCCCIIIISSSSIIIIOOOONNNN (defined in ccccoooommmmppppiiiilllleeeerrrr....hhhh.) virtual RWvostream& fffflllluuuusssshhhh(); Send the contents of the stream buffer to output immediately. virtual RWvostream& ppppuuuutttt(char c); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the cccchhhhaaaarrrr cccc to the output stream, preserving its value using a portable format. This member only preserves ASCII numerical codes, not the coresponding character symbol. virtual RWvostream& ppppuuuutttt(wchar_t wc); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the wide character wwwwcccc to the output stream, preserving its value using a portable format. PPPPaaaaggggeeee 5555 RRRRWWWWppppoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) RRRRWWWWppppoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) virtual RWvostream& ppppuuuutttt(unsigned char c); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the uuuunnnnssssiiiiggggnnnneeeedddd cccchhhhaaaarrrr cccc to the output stream, preserving its value using a portable format. virtual RWvostream& ppppuuuutttt(const char* p, size_t N); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the vector of cccchhhhaaaarrrrs starting at pppp to the output stream, preserving their values using a portable format. Note that the characters will be treated as literal numbers (i.e., not as a character string). virtual RWvostream& ppppuuuutttt(const wchar_t* p, size_t N); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the vector of wide cccchhhhaaaarrrrs starting at pppp to the output stream, preserving their values using a portable format. Note that the characters will be treated as literal numbers (i.e., not as a character string). virtual RWvostream& ppppuuuutttt(const unsigned char* p, size_t N); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the vector of uuuunnnnssssiiiiggggnnnneeeedddd cccchhhhaaaarrrrs starting at pppp to the output stream using a portable format. The characters should be treated as literal numbers (i.e., not as a character string). virtual RWvostream& ppppuuuutttt(const short* p, size_t N); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the vector of sssshhhhoooorrrrtttts starting at pppp to the output stream using a portable format. virtual RWvostream& ppppuuuutttt(const unsigned short* p, size_t N); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the vector of uuuunnnnssssiiiiggggnnnneeeedddd sssshhhhoooorrrrtttts starting at pppp to the output stream using a portable format. virtual RWvostream& ppppuuuutttt(const int* p, size_t N); PPPPaaaaggggeeee 6666 RRRRWWWWppppoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) RRRRWWWWppppoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++)))) Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the vector of iiiinnnntttts starting at pppp to the output stream using a portable format. virtual RWvostream& ppppuuuutttt(const unsigned int* p, size_t N); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the vector of uuuunnnnssssiiiiggggnnnneeeedddd iiiinnnntttts starting at pppp to the output stream using a portable format. virtual RWvostream& ppppuuuutttt(const long* p, size_t N); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the vector of lllloooonnnnggggs starting at pppp to the output stream using a portable format. virtual RWvostream& ppppuuuutttt(const unsigned long* p, size_t N); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the vector of uuuunnnnssssiiiiggggnnnneeeedddd lllloooonnnnggggs starting at pppp to the output stream using a portable format. virtual RWvostream& ppppuuuutttt(const float* p, size_t N); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the vector of ffffllllooooaaaatttts starting at pppp to the output stream using a portable format. virtual RWvostream& ppppuuuutttt(const double* p, size_t N); Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm. Store the vector of ddddoooouuuubbbblllleeees starting at pppp to the output stream using a portable format. virtual RWvostream& ppppuuuuttttSSSSttttrrrriiiinnnngggg(const char*s, size_t N); Store the character string, iiiinnnncccclllluuuuddddiiiinnnngggg eeeemmmmbbbbeeeeddddddddeeeedddd nnnnuuuullllllllssss, starting at s to the output string. PPPPaaaaggggeeee 7777